package com.jiusuzu.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jiusuzu.common.pojo.EUTreeNode;
import com.jiusuzu.common.pojo.JiusuzuResult;
import com.jiusuzu.pojo.TbContent;
import com.jiusuzu.service.ContentService;

/**
 * 网站内容管理
 * 
 * @author 李锐洋
 */
@Controller
@RequestMapping("/content")
public class ContentController {
	@Autowired
	private ContentService contentService;

	/**
	 * 插入一条网站内容
	 * 
	 * @param content
	 * @return
	 */
	@RequestMapping("/save")
	@ResponseBody
	public JiusuzuResult insertContent(TbContent content) {
		JiusuzuResult result = contentService.insertContent(content);
		return result;
	}

	@RequestMapping("/list")
	@ResponseBody
	public List<EUTreeNode> getContentCatList(@RequestParam(value = "id", defaultValue = "1") Long parentId) {
		List<EUTreeNode> list = contentService.getCategoryList(parentId);
		return list;
	}
}
